package client

import (
	"context"
	"github.com/micro/go-micro/v2/client"
	"github.com/micro/go-micro/v2/client/grpc"
	"kop/framework/wrapper"
	"kop/modules/achievement/configuration/a_type"
	"kop/pb/service"
)

var AchievementService service.AchievementService

func init() {

	var c = grpc.NewClient(client.Wrap(wrapper.ClientLogWrapper))
	_ = c.Init()

	//s.Init(test.Flags()...)

	AchievementService = service.NewAchievementService("go.micro.srv.role", c)

}

func AddNumber(roleID int32, typ a_type.Type, n int64) {

	var req = service.AchievementRequest{
		RoleID: roleID,
		Type:   int32(typ),
		Number: n,
	}

	_, _ = AchievementService.AddNumber(context.Background(), &req)

}

func SetNumber(roleID int32, typ a_type.Type, n int64) {

	var req = service.AchievementRequest{
		RoleID: roleID,
		Type:   int32(typ),
		Number: n,
	}

	_, _ = AchievementService.SetNumber(context.Background(), &req)
}

func CaptainNum(roleID int32) {

	AddNumber(roleID, a_type.CaptainNum, 1)
}

func MaidNum(roleID int32) {

	AddNumber(roleID, a_type.MaidNum, 1)
}
